# status_codes.py

class StatusCodes:
    # 成功
    SUCCESS = 200

    # 通用失败
    TASK_FAILED = 6001
    TIMEOUT = 6002
    PARAMETER_ERROR = 6003
    CLIENT_INIT_ERROR = 6004
    IMAGE_PROCESS_ERROR = 6005
    IMAGE_PROCESS_ERROR_MODEL = 6006

    # 检测细分
    INPUT_IMAGE_INVALID_GPT = 7101
    INPUT_IMAGE_INVALID_GPT_THRESHOLD = 7301
    INPUT_IMAGE_INVALID_MODEL = 7102
    INPUT_TEXT_INVALID_GPT = 7103
    INPUT_TEXT_INVALID_MODEL = 7104
    INPUT_TEXT_INVALID_MODEL_THRESHOLD = 7302
    OUTPUT_VIDEO_INVALID_GPT = 7201
    OUTPUT_VIDEO_INVALID_GPT_THRESHOLD = 7303
    OUTPUT_VIDEO_INVALID_MODEL = 7202

    # 文案映射
    _CODE_MSG = {
        SUCCESS: "操作成功",
        TASK_FAILED: "处理任务失败",
        TIMEOUT: "任务超时",
        PARAMETER_ERROR: "参数错误",
        CLIENT_INIT_ERROR: "对接API端初始化失败",
        IMAGE_PROCESS_ERROR: "图片处理失败",
        IMAGE_PROCESS_ERROR_MODEL: "模型图片下载失败",

        INPUT_IMAGE_INVALID_GPT: "输入图片包含敏感信息，请选择其它图片。",
        INPUT_IMAGE_INVALID_GPT_THRESHOLD: "输入图片包含敏感信息，请选择其它图片。(GPT检测失败但是不超过阈值)",
        INPUT_IMAGE_INVALID_MODEL: "输入图片包含敏感信息，请选择其它图片。",
        INPUT_TEXT_INVALID_GPT: "输入提示词包含敏感信息，请重新输入。",
        INPUT_TEXT_INVALID_MODEL: "输入提示词包含敏感信息，请重新输入。",
        INPUT_TEXT_INVALID_MODEL_THRESHOLD: "输入提示词包含敏感信息，请重新输入(GPT检测失败但是不超过阈值)。",
        OUTPUT_VIDEO_INVALID_GPT: "AIGC生成内容包含敏感信息。",
        OUTPUT_VIDEO_INVALID_GPT_THRESHOLD: "AIGC生成内容包含敏感信息。(GPT检测失败但是不超过阈值)",
        OUTPUT_VIDEO_INVALID_MODEL: "AIGC生成内容包含敏感信息。",
    }

    # 反向索引：msg -> code
    _MSG_CODE = {v: k for k, v in _CODE_MSG.items()}

    @classmethod
    def get_msg(cls, code: int) -> str:
        """根据状态码返回文案。"""
        return cls._CODE_MSG.get(code, "未知错误")

    @classmethod
    def get_code(cls, msg: str) -> int | None:
        """根据文案返回状态码；找不到返回 None。"""
        return cls._MSG_CODE.get(msg)

    # 示例
    # from status_codes import StatusCodes as SC
    #
    # print(SC.get_msg(SC.INPUT_IMAGE_INVALID_GPT))
    # # → 输入图片包含敏感信息，请选择其它图片。
    #
    # print(SC.INPUT_IMAGE_INVALID_GPT)
    # → 7101
